package com.ruoyix.flowable.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyix.common.annotation.Log;
import com.ruoyix.common.annotation.RepeatSubmit;
import com.ruoyix.common.core.controller.BaseController;
import com.ruoyix.common.core.domain.R;
import com.ruoyix.common.enums.BusinessType;
import com.ruoyix.flowable.domain.vo.BpmTaskApproveVo;
import com.ruoyix.flowable.service.IBpmProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("/flowable/api")
public class FlowableApiController extends BaseController {

    private final IBpmProcessInstanceService iBpmProcessInstanceService;
    @SaCheckPermission("flowable:bpmProcessInstance:add")
    @Log(title = "业务流程实例", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @GetMapping("/add")
    public R<BpmTaskApproveVo> add(String processDefinitionKey, String formVariables) {
        return R.ok(iBpmProcessInstanceService.addBsProcessInstance(processDefinitionKey, formVariables));
    }
}
